<?php

namespace Home\Controller;

use Org\ZpRedis;
use Monolog\Logger;
use Monolog\MyHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Formatter\LineFormatter;
use Common\Controller\HomebaseController;
class TestController extends HomebaseController {
	public function test_send_mail(){
		$_SESSION['user']['uname'] = 'test';
		$_SESSION['user']['u_email']='lhf2008@yeah.net';
		$rs = $this->sendEmaill_to_User('123456');
		echo '<pre>';print_r($rs);exit;
	}
	public function test_monolog(){
		$mongolog = new \Org\Monolog\MonologClient;
		echo 11;exit;
	}
	public function test_user_agent(){
		layout(false);
		$this->display();
	}
	public function php_v(){
		layout(false);
		phpinfo();
	}
	public function redis(){
		//S('test_redis','this is a demo',array('type'=>'redis','expire'=>300));
		echo S('test_redis');
	}
	public function queue(){
		$queue = ZpRedis::getInstance('msg');
		
		//for($i=0;$i<5;$i++){
			//$queue->push($i);
		//}
		//$queue->push('ccccccc');
		//$queue->push('aaaaaa');
		//$queue->push('bbbbbb');
		/*
		$value = $queue->pop();
		if(!$value){
			//逻辑处理
			
			//删除
			$queue->delValue($value,1);
		}*/
		//$len   = $queue->len();
		//$index = $queue->lindex(1);
		//$all = $queue->all(0,-1);
		//$delValue = $queue->delValue('bbbbbb',1);
		//删除队列
		//$queue->flushQueue();
		echo '<pre>';print_r($value);
	}
	//获取所有队列
	public function getAllQueue(){
		$queue = ZpRedis::getInstance('msg');
		$all = $queue->all(0,-1);
		echo '<pre>';print_r($all);
	}
	//获取redis所有键值
	public function getAll(){
		$queue = ZpRedis::getInstance('msg');
		$all = $queue->getKeys();
		echo '<pre>';print_r($all);
	}
	//查看数据库现在有多少key
	public function numKeys(){
		$queue = ZpRedis::getInstance('msg');
		$all = $queue->numKeys();
		echo '<pre>';print_r($all);
	}
	/*记事本 vue部署*/
	public function vue(){
		layout(false);
		C('VIEW_PATH','');
		$this->display();
	}
	/*vue跨域请求 接收测试*/
	public function axios(){
		header('Access-Control-Allow-Origin: *');
		header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,PATCH,OPTIONS');
		header('Access-Control-Allow-Credentials: true');
		
		$email = I('get.email','');
		$pwd = I('get.pwd','');
		echo json_encode(['rs'=>'ok','msg'=>$email.$pwd]);
	}
	/*阿里云 移动推送*/
	public function pushToAndroid(){
		echo 'Hello';
	}
	
	//程序执行时间
	public function performTime(){
		list($usec,$sec)=explode(' ',microtime());
		$startTime = $usec + $sec;
		for($i=0;$i<1000000;$i++){
			mt_rand(1,100);
		}
		
		list($usec1,$sec1)=explode(' ',microtime());
		$endTime = $usec1 + $sec1;
		
		echo $endTime-$startTime;exit;
	}
}